<template>
  <div class="recharge-status-page common-page">
    <div class="cell-box">
      <div class="title">
        <span>充值手机号</span>
        <span>{{ rechargeStatusInfo.tel }}</span>
      </div>
      <span class="wait" v-if="rechargeStatusInfo.status === 1">正在获取</span>
      <span class="wait" v-if="rechargeStatusInfo.status === 100"
        >等待充值</span
      >
      <span class="wait" v-if="rechargeStatusInfo.status === 101">充值中</span>
      <span class="value" v-if="rechargeStatusInfo.status === 200"
        >充值成功</span
      >
      <span class="value" v-if="rechargeStatusInfo.status === 500"
        >充值失败</span
      >
      <span
        class="value"
        v-if="
          rechargeStatusInfo.status !== 1 &&
          rechargeStatusInfo.status !== 100 &&
          rechargeStatusInfo.status !== 101 &&
          rechargeStatusInfo.status !==200 &&
          rechargeStatusInfo.status !==500
        "
        >状态获取失败</span
      >
    </div>
    <div class="box-info">
      <span>盲盒奖品</span>
      <commodity-item :boxInfo="boxInfo"></commodity-item>
    </div>
    <div class="order-info">
      <div class="order-info-detail">
        <span>订单编号：</span>
        <span>{{ rechargeStatusInfo.orderId }}</span>
      </div>
      <div class="order-info-detail">
        <span>订单生成时间：</span>
        <span>{{ rechargeStatusInfo.createTime }}</span>
      </div>
      <div class="btn-box">
        <div @click="onLeaveMessageClick">
          <img :src="leaveMessage" alt="" />
          <span>留言反馈</span>
        </div>
        <div @click="onContactUsClick">
          <img :src="customerIcon" alt="" />
          <span>联系我们</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import apBox from "@/common/api/apBox";
import Share from "./mixin/share";
import { mapGetters } from "vuex";
import CommodityItem from "@/components/CommodityItem";
export default {
  name: "rechargeStatus",
  components: {
    [CommodityItem.name]: CommodityItem,
  },
  mixins: [Share],

  computed: {
    ...mapGetters(["userInfo"]),
  },
  data() {
    return {
      boxInfo: {},
      leaveMessage: require("../common/imgs/leave-message2.png"),
      customerIcon: require("../common/imgs/customer-icon2.png"),
      rechargeStatusInfo: {
        status: 1,
      },
      boxId: "",
    };
  },
  created() {
    this.setShare();
    if (this.$route.query.boxInfo) {
      this.boxInfo = JSON.parse(this.$route.query.boxInfo) || {};
      this.boxId = this.boxInfo.id;
      console.log(9999999999999999);
      console.log(this.boxInfo);
      this.getOrderInfoDetail();
    }
    if (this.$route.query.prizeInfo) {
      this.boxId = this.$route.query.boxId;
      this.boxInfo = JSON.parse(this.$route.query.prizeInfo) || {};
      // this.boxInfo = this.$route.query.prizeInfo|| {};
      console.log(88888888888888);
      console.log(this.boxId);
      console.log(this.boxInfo);
      this.getOrderInfoDetail();
    }
  },
  mounted() {},
  methods: {
    //  查询状态
    getOrderInfoDetail() {
      console.log("查询状态");
      console.log(this.boxId);
      this.$toast.loading();
      apBox
        .getRechargeStatus({
          userBoxId: this.boxId,
          userId: this.userInfo.userId,
        })
        .then((data) => {
          this.rechargeStatusInfo = data.data;
          this.$toast.clear();
        });
    },
    onLeaveMessageClick() {
      this.$router.push({
        path: "/leaveMessage",
      });
    },
    onContactUsClick() {
      this.$router.push({
        path: "/contactWays",
      });
    },
  },
};
</script>

<style lang="less" scoped>
@import "../common/css/common.less";
.cell-box {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  height: 98px;
  padding: 0 24px;
  box-sizing: border-box;
  border-radius: 12px;
  background: #ffffff;
  .title {
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
    span {
      font-size: 30px;
      color: #222222;
    }
    span:nth-child(2) {
      margin-left: 64px;
    }
  }
  .value {
    font-size: 30px;
    color: #df5438;
  }
  .wait {
    font-size: 30px;
    color: #888888;
  }
}
.box-info {
  background: #ffffff;
  margin-top: 20px;
  border-radius: 12px;
  > span {
    display: inline-block;
    width: 100%;
    padding: 24px 24px 0 24px;
    box-sizing: border-box;
    font-size: 28px;
    color: #555555;
    line-height: 40px;
  }
}
.order-info {
  width: 100%;
  padding: 24px 24px 0 24px;
  box-sizing: border-box;
  background: #ffffff;
  border-radius: 12px;
  margin-top: 20px;
  .order-info-detail {
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
    width: 100%;
    padding-bottom: 24px;
    span {
      font-size: 26px;
      color: #888888;
      line-height: 37px;
    }
    span:first-child {
      margin-right: 40px;
    }
  }
  .btn-box {
    border-top: 1px solid #e5e5e5;
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    div {
      width: 50%;
      display: flex;
      flex-direction: row;
      justify-content: center;
      align-items: center;
      padding: 30px 0;
      span {
        font-size: 30px;
        color: #222222;
      }
      img {
        width: 32px;
        height: 32px;
        margin-right: 11px;
      }
    }
  }
}
</style>
